#include <stdio.h>
void tian(int year, int mon)
{
	int run[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	int pin[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	int riqi = 0;

	if (year % 4 == 0)
	{
		riqi = run[mon - 1];
		printf("%d\n", riqi);
	}
	else
	{
		riqi = pin[mon - 1];
		printf("%d\n", riqi);
	}
}

int main()
{
	int a, b;

	while ((scanf("%d%d", &a, &b)) != EOF)
	{
		tian(a, b);
	}
	return 0;
}

